/**
 * 
 * 客户列表 医生
 * 
 * */
import React, { useCallback, useMemo, useState } from 'react';
import Header from '@/component/layout/Header/Header';
import ListTitle from "@/component/layout/ListTitle/ListTitle";
import CommonList from '@/component/common/CommonList/CommonList';
import { getDoctorList } from '@/network/protocol';

import qs from "querystring";

import './style.less';
import { useEffect } from 'react';
const img1 = <img alt="" className="edit" src={require('../../assests/img/edit.png')} />
const pageSize = 20;

const DocList = (props) => {
  const id = useMemo(() => {
    let search = props.location.search;
    if (!search) return;
    let str = search.slice(1);
    let param = qs.parse(str);
    return param.id
  }, [props.location.search])

  const [param, setParam] = useState({ pageIndex: 1, pageSize, salerId: id })

  const update = useCallback(() => {
    setParam({ ...param, pageIndex: param.pageIndex + 1 })
  }, [param])
  // const param = useMemo(() => {
  //   return {
  //     salerId: id,
  //     pageIndex: 1,
  //     pageSize: 10,
  //     area: 1
  //   }
  // }, [id])

  const DocList1 = useCallback((props) => {
    const { data } = props;
    return <div className="Customer-list-item-itembox">
      <div className="Customer-list-item">
        <p className="p1">
          <span>姓名：{data.name || '--'}</span>
          <span>医院：{data.hospital || '--'}</span>
        </p>
        <p className="p2">
          <span>级别：{data.level || '--'}</span>
          <span>电话：{data.telephone || '--'}</span>
        </p>
      </div>
    </div>

  }, [])

  useEffect(() => {
  }, [])
  return <>
    <Header center={<span>客户管理</span>} />
    <div className="global-content CustomerList-box">
      <div className="header-box">
        <ListTitle img={img1} text={'医生列表'} />
        {/* <div className="select-box">
          <p>地区选择</p>
          <img src={require('../../assests/img/down.png')} alt="" />
        </div> */}
      </div>
      <div className="list-box">
        <CommonList update={update} mapkey={'userId'} viewCmp={DocList1} method={getDoctorList} param={param} />
      </div>


    </div>
  </>

}


export default React.memo(DocList)

